package com.twu.biblioteca.Persistence;

import com.twu.biblioteca.library.items.User;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by aruna on 27/4/14.
 */
public class UserRepository {
    private static final Set<User> userslist = new HashSet<User>();
    public static void populateUsers()
    {
        userslist.add(new User("User1","Address1","Phone1","email@gmail.com","111-0001","password"));
        userslist.add(new User("User2","Address2","Phone2","email@gmail.com","111-0002","password"));

    }
    public static User getUserByLibraryNumber(String librarynumber) {
        for (User user : userslist) {
            if (user.getUserCredential().getLibraryNumber().equals(librarynumber))
                return user;

        }
        return null;
    }
    public static String getUserProfile(String librarynumber){
        User user=getUserByLibraryNumber(librarynumber);
        if(user != null)
        {
            if(user.isLoggedIn())
                return user.toString();
            else
                return "Please Login to see profile details";
        }
        else
            return "No such User Record found";
    }
        

}
